﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>用户信息</title>
    @*引入包*@
    <link href="~/Content/Easy UI/themes/icon.css" rel="stylesheet" />
    <link href="~/Content/Easy UI/themes/default/easyui.css" rel="stylesheet" />
    <script src="~/Content/Easy UI/script/jquery-1.11.1.js"></script>
    <script src="~/Content/Easy UI/script/jquery.easyui.min.js"></script>
    <script src="~/Content/Easy UI/script/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#UserTable").datagrid({
                fitColumns: true,
                toolbar: "#tb",
                pagination: true,
                singleSelect: true,
                rownumbers: true,
                url: "/UserInfo/GetListUserInfo",
                columns: [[
                    { field: 'U_ID', title: '用户编号', width: 222, align: "center" },
                    { field: 'U_LoginName', title: '登录名', width: 222, align: "center" },
                    { field: 'U_RealName', title: '真实姓名', width: 222, align: "center" },
                    { field: 'U_Sex', title: '性别', width: 222, align: "center" },
                    { field: 'U_Telephone', title: '联系电话', width: 222, align: "center" },
                    { field: 'U_Role', title: '用户角色', width: 222, align: "center" },
                    { field: 'U_CanDelete', title: '是否可是删除', width: 222, align: "center" },

                ]]
            });
            //查询
            $(".select").click(function () {
                $("#UserTable").datagrid("load", {
                    U_LoginName: $("#U_LoginName").val(),
                    U_RealName: $("#U_RealName").val(),
                    U_Telephone: $("#U_Telephone").val()
                })
            });
            //新增
            $(".insert").click(function () {
                //添加iframe
                $("#dlg").dialog({ width: 700, height: 500 }).dialog("setTitle", "新增").dialog("open")
                $("#frm1").attr("src", "/UserInfo/add");
            });
            //修改
            $(".Up").click(function () {
                //获取选中行
                var row = $("#UserTable").datagrid("getSelected");
                //判断是否存在行列号
                if (row != null) {
                    $("#dlg").dialog({ width: 700, height: 500 }).dialog("setTitle", "修改").dialog("open")
                    $("#frm1").attr("src", "/UserInfo/Edit/" + row.U_ID);
                } else {
                    $.messager.alert("提示", "请选择需要编辑的行", "warning");
                }

            });
            //删除
            //删除
            $(".Delate").click(function () {
                //获取选中行
                var row = $("#UserTable").datagrid("getSelected");
                //判断是否存在选中行
                if (row == null) {
                    $.messager.alert("提示", "请选择想要删除的行", "warning");
                } else {
                    if (row.U_ID) {
                        $.messager.confirm("温馨提示", "你确定要删除吗？", function (r) {
                            if (r) {
                                $.post("/UserInfo/Delete", { U_ID: row.U_ID }, function (data) {
                                    if (data.ResultStatus == 1) {
                                        //弹出框 删除成功
                                        $.messager.alert("提示", data.Msg, "info");
                                        //刷新页面
                                        $("#UserTable").datagrid("reload")
                                    } else {
                                        //弹出框 删除失败
                                        $.messager.alert("提示", data.Msg, "error");
                                    }
                                })

                            }

                        })
                    }
                    else {
                        $.messager.alert("提示", "该用户不存在", "warning");
                    }

                }

            })



        })
    </script>
</head>
<body>
    <form>
        <div>
            <table class="easyui-datagrid" id="UserTable"></table>
            <div id="tb">
                <a id="btn" href="javascript:" class="easyui-linkbutton insert" data-options="iconCls:'icon-add'">新增</a>
                <a id="btn" href="javascript:" class="easyui-linkbutton Up" data-options="iconCls:'icon-edit'">修改</a>
                <a id="btn" href="javascript:" class="easyui-linkbutton Delate" data-options="iconCls:'icon-remove'">删除</a>
                <br />
                登录名：<input id="U_LoginName" type="text" style="width:100px;height:20px;border:1px solid gray ;" />
                真实姓名：<input id="U_RealName" type="text" style="width:100px;height:20px;border:1px solid gray ;" />
                联系电话：<input id="U_Telephone" type="text" style="width:100px;height:20px;border:1px solid gray ;" />
                <a id="btn" href="javascript:" class="easyui-linkbutton select" data-options="iconCls:'icon-search'">搜索</a>
            </div>
            <div id="dlg" class="easyui-dialog" data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true">
                <iframe id="frm1" width="99%" height="99%" frameborder="0"></iframe>
            </div>
        </div>
    </form>
</body>
</html>
